﻿<%--
 *  File:    PriceListSummary.jsp
 *  @Author: Peter Shen
 *  Date:    Wednesday, October 16, 2002

 *  Copyright (C) 2000 - 2001 Oval Technologies, Inc.
 *  All rights reserved.
 *
 *  This software is the confidential and proprietary information of Oval
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>
 

<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java" %>
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>
<%@ page import="com.oval.util.*" %>

<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="http://dcms.oval.com/page/dcms" prefix="dcms" %>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>

<%
  Category cat = Category.getInstance("jsp.PriceListSummary2");
  String privilegeCode = "10502";
  String strModuleName = "APM";
  String strTableName = "ovpricelistsummary";
%>

<%@include file="/inc/PageDefault.inc"%>


<%@include file="/inc/FrmDefault.inc"%>
<%@include file="/inc/LocationDefault.inc"%>
<html>
<head>
<title>pricelistsummary</title>
<link rel="stylesheet" href="<%=request.getContextPath()%>/css/<%= strLanguageCode %>/main.css" type="text/css">
<LINK href="<%=request.getContextPath()%>/css/<%=strLanguageCode%>/main.htm" type=text/css>
<script language="JavaScript" src="js/ScriptLib.js"></script>
<script language="JavaScript" src="js/Calendar.js"></script>
<script>
  var orgselect=0;
  function page_selectorgpop()
  {
    orgselect=1;
      var strurl="masterdata/ogm/OrgSelect.jsp?<%= OvalTools.randomURL() %>&selectoption=owner&orgid=<custom:write name="userinfo" scope="session"  property="orgid"/>";
      var strstatus="height=250, width=600,top=100,left=100,toolbar=no, menubar=no, scrollbars=yes, resizable=no,location=no, status=no";
      if(popwindow!=null)
          popwindow.close();
      popwindow = window.open(strurl,"newwindows" ,strstatus);
  }
  function page_selectcustomerpop()
{
  orgselect=2;
	var strurl="masterdata/ogm/OrgSelect.jsp?<%= OvalTools.randomURL() %>&selectoption=distributor&orgid="+document.getElementsByName('orgid')[0].value;
    var strstatus="height=250, width=600,top=100,left=100,toolbar=no, menubar=no, scrollbars=yes, resizable=no,location=no, status=no";
    if(popwindow!=null)
        popwindow.close();
    popwindow = window.open(strurl,"newwindows" ,strstatus);
}
  function page_setOrg(orgid,orgname,orgcode)
{
  if(orgselect==1)
  {
    document.getElementsByName('orgid')[0].value=orgid ;
     document.getElementsByName('orgname')[0].value=orgname ;
    //alert(orgid+"****"+$('orgid').attr('value'));
    //alert(orgname+"****"+document.getElementByName('orgname'));
    popwindow=window.open("","newwindows" ,"");
    if(popwindow!=null)
        popwindow.close();
    __refresh();
  }
  else if(orgselect==2)
  {
       document.dispatcherform.customerid.value = orgid;
    document.dispatcherform.customername.value = orgname;
    popwindow=window.open("","newwindows" ,"");
    if(popwindow!=null)
        popwindow.close();
  }
}
function page_save()
{
  var begindate = "";
  var begindate1 = "";
  var expiredate = "";
  var expiredate1 = "";
 
  begindate=dateTransform(dispatcherform.begindate.value,'yyyy-MM-dd','<%=JspHelper.filterNull( session.getAttribute("dateformat") )%>');
  expiredate=dateTransform(dispatcherform.expiredate.value,'yyyy-MM-dd','<%=JspHelper.filterNull( session.getAttribute("dateformat") )%>');
  begindate1=timeCheck(dispatcherform.begindate1.value, 'hh:mm:ss', '<%=JspHelper.filterNull( session.getAttribute("timeformat") )%>')
  expiredate1=timeCheck(dispatcherform.expiredate1.value, 'hh:mm:ss', '<%=JspHelper.filterNull( session.getAttribute("timeformat") )%>')
  
  if(dispatcherform.begindate1.value == "" || isEmpty(dispatcherform.begindate1.value))
  	begindate1 = timeCheck('00:01:01', 'hh:mm:ss', '<%=JspHelper.filterNull( session.getAttribute("timeformat") )%>')
  if(dispatcherform.expiredate1.value == "" || isEmpty(dispatcherform.expiredate1.value))
  	expiredate1 = timeCheck('00:01:02', 'hh:mm:ss', '<%=JspHelper.filterNull( session.getAttribute("timeformat") )%>')
  		
	 if(dispatcherform.begindate.value == "")
  {
  	alert('<%= message.getMessageDesc("VALUE_NOT_NULL", label.getLabelName("L_BeginDate",false)) %>');
  	//return;
  }
 
  if(dispatcherform.expiredate.value == "")
  {
  	alert('<%= message.getMessageDesc("VALUE_NOT_NULL", label.getLabelName("L_ExpireDate",false)) %>');
  	//return;
  }
	if(check_date((begindate + " " + begindate1),(expiredate + " " + expiredate1)) == false)
	{
	  return;
	}	

   if(document.dispatcherform.orggroupid ==null || document.dispatcherform.orggroupid.value == "" ){
		var opt1 = document.dispatcherform.orggroupid.options;
		for(var j = 0;j < opt1.length;j++)
        {
          if(opt1[j].value == "")
            opt1[j].value = " ";
        }
	}

  if(document.dispatcherform.qtytype ==null || document.dispatcherform.qtytype.value == "" ){
		var opt2 = document.dispatcherform.qtytype.options;
		for(var k = 0;k < opt2.length;k++)
        {
          if(opt2[k].value == "")
            opt2[k].value = " ";
        }
	}
	
  if(document.dispatcherform.prgid ==null || document.dispatcherform.prgid.value == "" ){
		var opt3 = document.dispatcherform.prgid.options;
		for(var l = 0;l < opt3.length;l++)
        {
          if(opt3[l].value == "")
            opt3[l].value = " ";
        }
	}
 
  if(document.dispatcherform.productbrandcode.value == null || document.dispatcherform.productbrandcode.value == "" )
    document.dispatcherform.productbrandcode.value = " ";
  if(!checkForm(document.dispatcherform))return;
//  if(!formatDate(document.dispatcherform))return;
  if(document.dispatcherform.priority.value < 0)
  {
  	alert("<%=message.getMessageDesc("VALUE_NOT_LESSTHAN",label.getLabelName("L_Priority",false),new String("0"))%>");
  	//return;
  }

  dispatcherform.begindate.value = begindate + " " + begindate1;
  dispatcherform.expiredate.value = expiredate + " " + expiredate1;	

  emptyToNull(document.dispatcherform);
 
  dispatcherform.actionname.value="save";
  if(dispatcherform.pricelistid.value=='')
     __save('mydispatcherformid',true);
   else
    __save('mydispatcherformid');
 
}
function check_date(startdate,enddate)
{
	if(startdate != "" && enddate != ""){
		if (toDate(startdate,'yyyy-MM-dd hh:mm:ss') >= toDate(enddate,'yyyy-MM-dd hh:mm:ss')){
			 alert('<%= message.getMessageDesc("CAN_NOT_LATE_THAN", label.getLabelName("L_StartDate",false), label.getLabelName("L_ExpireDate",false)) %>');
		     return false;
		};
	}
}
function page_calctypechange()
{
  dispatcherform.calcfactcode.value = dispatcherform.calctypeidforcontral.options[dispatcherform.calctypeid.selectedIndex].text;
  dispatcherform.calctypeidforcontral.options[dispatcherform.calctypeid.selectedIndex].selected=true;
}
function checkstatus()
{
  var obj=getElementsByColumnName("status");
  alert(getElementsByColumnName("status")[0].value);
  // alert("obj.length>0="+(obj.length>0));
   // alert("obj[0]!=null="+obj[0]!=null);
  //  alert("obj.value!=null="+(obj[0].value!=null));
  //  alert("obj.value==10="+(obj[0].value==10));
  if(obj.length>0 && obj[0]!=null && obj[0].value!=null && obj[0].value==10)
  {
  //  alert(true);
    return true;
  }
  // alert(false); 
  __alert("<%=message.getMessageDesc("CAN_NOT_EDIT_IT")%>");
  return false
}
function checkdeletestatus()
{
  var objs=getCheckedCheckBoxElements();
  //alert(objs.length);
  if(objs.length>0)
  {
    for(var i=0;i<objs.length;i++)
    {
      if(getCheckBoxAttrValueByColumnName(objs[i],"status")!='10')
        return false;
    }
  }
  return true;
}
function page_export()
{
  __export("CSV",true);
}
</script>  
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
 
<dcms:summary id="apm.pricelistsummary" needExportCSV="true" needExportXLSX="true" needNew="true" needEdit="true" needSubmit="true" preDeleteFunction="checkdeletestatus"  preEditFunction="checkstatus" needDelete="true" titalName="<%=label.getLabelName("L_PriceList")%>" summaryDataName="pricelistsummary" subjectcode="206">
  <dcms:param name="orgid" property="session:userinfo.orgid"/>
  <dcms:otherSearchCondition  >
  <%= label.getLabelName("L_Organization")+label.getLabelName("L_Colon") %>
      <input type="hidden" name="mytest" value="11"/>
          <custom:text  name="userinfo" property="orgname" scope="session" readonly="true" size="25" label="L_Organization" />
        <a onclick='javascript:page_selectorgpop();'><custom:button type="3" label="L_Asterisk" imgsrc="flash.gif" border="0"/></a>
  </dcms:otherSearchCondition>  
  <dcms:summaryAction actionFuction="page_cope" labelCode="L_Copy" styleWidth="60"/> 
  <dcms:summaryAction actionFuction="page_export" labelCode="L_Export" styleWidth="60"/> 
   
  <dcms:summaryDetailAction actionFuction="__back" labelCode="L_Copy" styleWidth="70"/>
  <dcms:summaryDetailAction actionFuction="page_cope" labelCode="L_Save" columnName="status" columnValues="10,40" styleWidth="60"/> 
  <dcms:summaryDetailAction actionFuction="page_cope" labelCode="L_Add" columnName="status" columnValues="10,40"  exp="(oval:indexof(pricelistcode,\"8\") >0 ) or (pricelistcode eq \"PL100023\") " styleWidth="60"/> 
   <dcms:summaryDetailAction actionFuction="__submit" labelCode="L_Submit"  styleWidth="60"/> 
   <dcms:summaryDetailAction actionFuction="__agree" labelCode="L_Agree"  styleWidth="60"/> 
   <dcms:summaryDetailAction actionFuction="__deny" labelCode="L_Refuse"  styleWidth="60"/> 
      
  <dcms:summaryTab id="mainTab" name="<%=label.getLabelName("L_Summary")%>"  href="<%=request.getContextPath()+"/apm/PriceListEditMain.jsp"%>"/> 
  <dcms:summaryTab id="customTab" name="<%=label.getLabelName("L_MapplyCustomer")%>"  href="bbb.jsp"/> 
  <dcms:summaryTab id="itemTab" name="<%=label.getLabelName("L_Applyitem")%>"  href="ccc.jsp"/> 
  <dcms:summaryTab id="mappingTab" name="<%=label.getLabelName("L_MapplyOF")%>"  href="ddd.jsp"/> 
  <dcms:summaryTab id="detailTab" name="<%=label.getLabelName("L_Detail")%>"  href="<%=request.getContextPath()+"/apm/EditPriceListDetail-Dis.jsp"%>"/> 
  <dcms:detailHeaderOther>
    <table  width="100%" cellspacing="0" cellpadding="0" border="0">
   <tr>
            <td><span class="b">定价单号：</span>{pricelistcode}</td>
         
            <td class="td_right"><span class="b">状态：{statusname}</span></td>
          </tr> 
        </table> 
  </dcms:detailHeaderOther>
      
</dcms:summary>

</body>
</html>